//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.dajie.pt.service;

import com.dajie.infra.user.InfraUserServiceContext;
import com.dajie.infra.user.model.UserBase;
import com.dajie.infra.user.service.UserBaseService;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class IsRegister {
    private static Logger logger = LoggerFactory.getLogger(IsRegister.class);
    public static final UserBaseService userService = InfraUserServiceContext.getInstance().getUserService();
    public static Connection conn_djgk = null;
    public static Connection conn_xtj = null;

    public IsRegister() {
        conn_djgk = this.getConn_DAJIEAPP();
        conn_xtj = this.getConn_DB_WXAPP();
    }

    public static void main(String[] args) {
        String mobiles = args[0];
        String type = args[1];
        System.out.println("-=-=" + type + mobiles.split(";").length);
        IsRegister invoke = new IsRegister();
        System.out.println(type + "\r\n" + invoke.getResult(mobiles, type));
    }

    public String getResult(String mobiles, String type) {
        try {
            StringBuffer e = new StringBuffer();
            String[] mobile = mobiles.split(";");
            String[] arr;
            int len;
            int i;
            String mob;
            if (type.equals("xtj")) {
                arr = mobile;
                len = mobile.length;

                for (i = 0; i < len; ++i) {
                    mob = arr[i];
                    if (this.isXTJ(mob)) {
                        e.append(mob + ":" + 1 + ";");
                    } else {
                        e.append(mob + ":" + 0 + ";");
                    }
                }
            } else if (type.equals("dajie")) {
                arr = mobile;
                len = mobile.length;

                for (i = 0; i < len; ++i) {
                    mob = arr[i];
                    if (this.isDAJIE(mob)) {
                        e.append(mob + ":" + 1 + ";");
                    } else {
                        e.append(mob + ":" + 0 + ";");
                    }
                }
            } else if (type.equals("djgk")) {
                arr = mobile;
                len = mobile.length;

                for (i = 0; i < len; ++i) {
                    mob = arr[i];
                    if (this.isDJGK(mob)) {
                        e.append(mob + ":" + 1 + ";");
                    } else {
                        e.append(mob + ":" + 0 + ";");
                    }
                }
            } else if (type.equals("rcwd")) {
                arr = mobile;
                len = mobile.length;

                for (i = 0; i < len; ++i) {
                    mob = arr[i];
                    if (this.isRCWD(mob)) {
                        e.append(mob + ":" + 1 + ";");
                    } else {
                        e.append(mob + ":" + 0 + ";");
                    }
                }
            }

            return e.toString();
        } catch (Exception var9) {
            var9.printStackTrace();
            return "--------------";
        }
    }

    public boolean isRCWD(String mobile) {
        boolean flag = false;
        UserBase userBase = userService.getUserByPhone(mobile);
        if (userBase != null) {
            flag = true;
        }

        return flag;
    }

    public boolean isDAJIE(String mobile) {
        boolean flag = false;
        UserBase userBase = userService.getUserByPhone(mobile);
        if (userBase != null) {
            flag = true;
        }

        return flag;
    }

    public boolean isXTJ(String mobile) {
        Statement state = null;
        ResultSet rs = null;
        boolean flag = false;

        try {
            state = conn_xtj.createStatement();
            String e = "select count(1) from tb_xtj_user where mobile = \'%s\' and mobile_status = 2";
            String sql = String.format(e, new Object[]{mobile});
            rs = state.executeQuery(sql);
            if (rs.next() && rs.getInt(1) > 0) {
                flag = true;
            }
        } catch (SQLException var15) {
            var15.printStackTrace();
        } finally {
            try {
                rs.close();
                state.close();
            } catch (SQLException var14) {
                var14.printStackTrace();
            }

        }

        return flag;
    }

    public boolean isDJGK(String mobile) {
        boolean flag = false;
        UserBase userBase = userService.getUserByPhone(mobile);
        if (userBase == null) {
            return false;
        } else {
            int uid = userBase.getUid().intValue();
            Statement statement = null;
            ResultSet resultSet = null;

            try {
                statement = conn_djgk.createStatement();
                resultSet = statement.executeQuery("select count(1) from user_account where userId = " + uid);
                if (resultSet.next() && resultSet.getInt(1) > 0) {
                    flag = true;
                }
            } catch (SQLException var16) {
                var16.printStackTrace();
            } finally {
                try {
                    resultSet.close();
                    statement.close();
                } catch (SQLException var15) {
                    var15.printStackTrace();
                }

            }

            return flag;
        }
    }

    public Connection getConn_DBUSER() {
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:cobar://cobarvip:12001/DB_USER_PT?autoCommit=true&autoReconnect=true&useUnicode=true&tinyInt1isBit=false&zeroDateTimeBehavior=round&characterEncoding=UTF-8&yearIsDateType=false&zeroDateTimeBehavior=convertToNull";
        String user = "platformol";
        String password = "platformol-3";
        Connection conn = null;

        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
            return conn;
        } catch (ClassNotFoundException var7) {
            ;
        } catch (SQLException var8) {
            ;
        }

        return null;
    }

    public Connection getConn_DAJIEAPP() {
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://db_querys_4:3337/dajieapp?autoCommit=true&autoReconnect=true&useUnicode=true&tinyInt1isBit=false&zeroDateTimeBehavior=round&characterEncoding=UTF-8&yearIsDateType=false&zeroDateTimeBehavior=convertToNull";
        String user = "platform_sel";
        String password = "dajie.platform)-";
        Connection conn = null;

        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
            return conn;
        } catch (ClassNotFoundException var7) {
            ;
        } catch (SQLException var8) {
            ;
        }

        return null;
    }

    public Connection getConn_DB_WXAPP() {
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://db_querys_6:3328/DB_WXAPP?autoCommit=true&autoReconnect=true&useUnicode=true&tinyInt1isBit=false&zeroDateTimeBehavior=round&characterEncoding=UTF-8&yearIsDateType=false&zeroDateTimeBehavior=convertToNull";
        String user = "platform_sel";
        String password = "dajie.platform)-";
        Connection conn = null;

        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
            return conn;
        } catch (ClassNotFoundException var7) {
            ;
        } catch (SQLException var8) {
            ;
        }

        return null;
    }
}
